<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="bean.dal.*,bean.entity.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<jsp:include page="top.jsp"></jsp:include>
	<%
	String clerkid = (String) session.getAttribute("clerkid");
	if(clerkid==null) clerkid="";
	System.out.println(clerkid);
		OrderManager orderM = new OrderManager();
		int id = Integer.parseInt(request.getParameter("id"));
		Orders orders = orderM.getOrdersById(id);
		User user = new User();
		UserManager userM=new UserManager();
		user=userM.getUserByUserId(orders.getUserid());
		Clerk clerk = new Clerk();
		ClerkManager clerkM=new ClerkManager();
		clerk=clerkM.getClerkByClerkId(orders.getClerkid());
	%>
	<script type="text/javascript" >
		function cancel(){
			location.href="/express/servlet/Order?modth=cancelreceive&id=<%=id%>";
		}
		function receive(){
			location.href="/express/servlet/Order?modth=receive&clerkid=<%=clerkid%>&id=<%=id%>";
		}
		function success(){
			var price=document.getElementById('price').value;
			location.href="/express/servlet/Order?modth=success&price="+price+"&id=<%=id%>";
		}
	</script>
<div align="center">
<table border="0" width="400px" cellspacing="0" cellpadding="0" id="table2">
	<tr><td height="50"></td></tr><tr>
   <td background="" width="400" height="86"></td>
   </tr>
</table>
<table border="0" width="360px" cellspacing="0" cellpadding="0" id="table1">
	<tr><td height="5"></td></tr><tr>
   <td class="login_msg" width="360" align="center">
	 <fieldset style="width: auto; margin: 0px auto;">
		  <legend>
		     <font style="font-size:15px" face="宋体">
		          订单详情
		     </font>
		  </legend>
		<form method="POST" action="/express/servlet/Order?modth=update&id=<%=id %>" name="login" id="login" onsubmit="return check()">
	<table border="1">
		<tr><td align="center">订单号：</td>
			<td><div id="orderid" name="orderid"><%=orders.getOrderid() %></div></td></tr>
		<tr><td align="center">账&nbsp;&nbsp;号：</td>
			<td><div id="userid" name="userid"><%=orders.getUserid() %></div></td></tr>
		<tr><td align="center">姓&nbsp;&nbsp;名：</td>
			<td><div id="username" name="username"><%=user.getUsername() %></div></td></tr>
		<tr><td align="center">电&nbsp;&nbsp;话：</td>
			<td><div id="tel" name="tel" ><%=orders.getTel() %></div></td></tr>
		<tr><td align="center"  width="86px">取件数量：</td>
			<td><div id="number" name="number"><%=orders.getNumber() %></div></td></tr>
		<tr><td align="center">取件信息：</td>
			<td><div id="information" name="information" height="70px"><%=orders.getInformation() %></div></td></tr>
		<tr><td align="center">配送员：</td>
			<td><div id="clerkid" name=""clerkid""><%=clerk.getClerkname() %></div></td></tr>
		<tr><td align="center">送货地址：</td>
			<td><div  id="location" name="location"><%=orders.getLocation() %></div></td></tr>
		<tr><td align="center">包裹类型：</td>
			<td><div id="typeid" name="typeid">
			<%
		 		TypeManager typeM=new TypeManager();
		 		Goods_type type = new Goods_type();
		 		type=typeM.getTypeByTypeId(orders.getTypeid());
			%><%=type.getTypename() %>
			</div></td></tr>
		<tr><td align="center">订单金额：</td>
			<td><div id="price" name="price""><%=orders.getPrice() %></div></td></tr>
		<tr><td align="center">优惠金额：</td>
			<td><div id="rebate" name="rebate"><%=orders.getRebate() %></div></td></tr>
		<tr><td align="center">下单时间：</td>
			<td><div id="orderdate" name="orderdate"><%=orders.getOrderdate() %></div></td></tr>
		<tr><td align="center">订单状态：</td>
			<td><div id="state" name="state"><%=orders.getState() %></div></td></tr>
		<tr><td align="center">备&nbsp;&nbsp;注：</td>
			<td><div id="bz" name="bz"><%=orders.getBz() %></div></td></tr>
		<tr><td align="center">支付方式：</td>
			<td><div id="pay" name="pay"><%=orders.getPay() %></div></td></tr>
		<tr><td align="center">支付状态：</td>
			<td><div id="pay_state" name="pay_state"><%=orders.getPay_state() %></div></td></tr>
	</table>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <center><%if(orders.getState().equals("已接单")) {%>
		 <input type="button" value="完成订单" onclick="success()"/>&nbsp;&nbsp;
		 <%session.setAttribute("price",orders.getPrice()); %> 
		 <input type="button" value="取消接单" onclick="cancel()"/>&nbsp;&nbsp; <%}else{ 
		 if(orders.getState().equals("已下单")){%>
          <input type="button" value="接单" onclick="receive()"/>&nbsp;&nbsp; <%} }%>
		 <a href="clerk/index.jsp"><input type="button" value="返回"/></a></center>
		 </form>
	 </fieldset>
	</td>
	</tr>
</table>
</div>
  </body>
</html>
